 <?php
class Staticpage extends Controller
{
	function __construct()
	{
		parent::__construct();
        
        $this->load->library('session');
        
		 if($this->session->userdata('admin') == '')
		 {    
		     redirect('admin');
		 }
        
		$this->load->model('staticpage_model');
	}
	
	function index()
	{   
        $data['query'] = $this->staticpage_model->getresultpages();
		
		$this->load->view(TEMPLATE_NAME.'/admin/staticpage_view',$data);
	}
	
	function edit($ids)
	{
        $this->load->helper(array('form'));
		$this->load->library('form_validation');
        //$ids = $this->uri->segment(4);
		$data['query'] = $this->staticpage_model->getresultbyid($ids);
		if($this->input->post('submit') != '')
		{
			$this->form_validation->set_rules('title','Title','required|trim|xss_clean|max_length[255]');			
			$this->form_validation->set_rules('subtitle','Subtitle','required|trim|xss_clean|max_length[255]');			
			$this->form_validation->set_rules('content','Content','required|trim|xss_clean');			
			$this->form_validation->set_rules('meta_keyword','Meta Keyword','max_length[255]');			
			$this->form_validation->set_rules('meta_description','Meta Description','required|trim|xss_clean|max_length[255]');
			
			//$this->validation->set_fields($fields);
			
			//$this->form_validation->set_message('title', 'The title mustnot be empty');
			
			if ($this->form_validation->run() == TRUE)
			{
                if($this->staticpage_model->update() == TRUE)
				{
                    redirect('admin/staticpage');
				}
			}
		}
		
		
		$this->load->view(TEMPLATE_NAME.'/admin/staticpage_edit_view',$data);
	}
    
}
?>